const list = <T>(formState:Record<string,any>,getApi:any,result:string)=>{
    let data = ref<T[]>([])
    let formRef = ref()
    const page = reactive({
        currentPage: 1,
        pageSize: 20,
        totalResult: 0
    })
    const getData = ()=>{
        getApi({
            ...formState,
            page:page.currentPage,
            size:page.pageSize
        }).then((res:any)=>{
            if(res.code==200){
                data.value = res.result[result] 
                page.totalResult = res.result.total
            }
        })
    }
    const reset=()=>{
        formRef.value.resetFields()
        getData()
    }

    onMounted(()=>{
        getData()
    })
    return {
        getData,
        data,
        page,
        formRef,
        reset
    }
}
export default list